﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;

using BusinessLogic.BusinessRules;
using BusinessLogic.ClassFactory;
using DataAccess;
using Model;
using EncryptUtily;
using IssueCommon;
using Common;
namespace RichECMS.IWebServices
{
    /// <summary>
    /// RegistWebSite 的摘要说明
    /// 该模块主要用于
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    public class UpdateWebSiteInfo : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strName">UserName</param>
        /// <param name="strPsw">UserPsw</param>
        /// <param name="strWebsiteNo">WebsiteNo</param>
        /// <param name="strBeginTime">EndTime</param>
        [WebMethod]
        public int RegistWebSiteUpdateNo(string strName, string strPsw, string strNo, string strTime)
        {
            int strReturn = 0;
            using (UserManageInfoFactory objUserFactory = new UserManageInfoFactory())
            {
                string strUserName = EncryptUtily.EncryptUtily.LoginDecrypt(strName);
                string strUserPsw = EncryptUtily.EncryptUtily.LoginDecrypt(strPsw);
                UserManageInfo objUserManageInfo = objUserFactory.CreatorBySql(string.Format("chvUserName ={0}", strName.ToString().Trim()));
                if (objUserManageInfo != null)
                {
                    if (EncryptUtily.EncryptUtily.LoginDecrypt(objUserManageInfo.DataItem.chvLoginPsw) == strUserPsw)
                    {
                        using (ServerVariableFactory objFactory = new ServerVariableFactory())
                        {
                            ServerVariable objServerVariable = objFactory.Creator();
                            if (objServerVariable != null)
                            {
                                objServerVariable.DataItem.chvImpowerNo = strNo;
                                objServerVariable.DataItem.dtmWebEnd = Convert.ToDateTime(strTime);
                                objServerVariable.Update();
                                strReturn = (int)Utility.RetrurnRegistState.Suecess;
                            }
                            else
                            {
                                strReturn = (int)Utility.RetrurnRegistState.NoRegist;
                            }
                        }
                    }
                    else
                    {
                        strReturn = (int)Utility.RetrurnRegistState.PswError;
                    }
                }
                else
                {
                    strReturn = (int)Utility.RetrurnRegistState.NoUser;
                }
            }
            return strReturn;
        }
    }
}
